package com.blog.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Service;

 



import com.blog.model.UserPoJo;
 
import com.blog.service.interfaces.IloginService;
import com.blog.dao.UserPoJoMapper;

@Service("loginService")
public class loginService implements IloginService {
	
	@Autowired
	UserPoJoMapper userMapper;
	@Autowired
	UserPoJo userPoJo;
	
	/*
	*已交给 spring security 管理！！！！！！！！！！！！！！！！！！！！
	*/
	/*登陆验证
	public boolean check2(String username, String password) {
		System.out.println(username);
		System.out.println(password);
		System.out.println(userMapper.selectByName(username).getPassword());
		System.out.println(PublicUtil.decrypt(userMapper.selectByName(username).getPassword()));
		return password.equals(PublicUtil.decrypt(userMapper.selectByName(username).getPassword()))?true:false;
	}*/

	//注册
	public int register(String username, String password) {
		userPoJo.setUsername(username);
		userPoJo.setPassword(PublicUtil.encrypt(password));
		userPoJo.setGroup(1);
		return userMapper.insertSelective(userPoJo);
	}


}
